import { toFix } from "@/utils/eam";
export const columns = [
  {
    prop: "factoryDeptName",
    label: "工厂",
    width: 80,
    conditionList: ["深圳工厂", "宜兴工厂"],
    fixed: true,
    mergeCell: true,
    background: "#F5F6F7",
    color: "#424656",
    enabledClick: false,
  },
  {
    prop: "lineName",
    label: "产线",
    width: 80,
    conditionList: [],
    fixed: true,
    mergeCell: true,
    background: "#F5F6F7",
    color: "#424656",
    enabledClick: false,
  },
  {
    prop: "produceMonth",
    label: "月份",
    width: 80,
    conditionList: [],
    fixed: false,
    mergeCell: true,
    background: "#F5F6F7",
    color: "#424656",
    enabledClick: false,
  },
  {
    prop: "produceEfficiency",
    label: "生产效率",
    width: 80,
    conditionList: [],
    formatter: (row, col) => {
      return ![undefined, null].includes(row[col.prop]) ? `${row[col.prop]}%` : "";
    },
    fixed: false,
    mergeCell: true,
    background: "#F5F6F7",
    color: "#424656",
    enabledClick: false,
    cellClass: (row, col) => {
      if (row.produceEfficiencyOk == "N") {
        return "warning-color";
      } else if (row.produceEfficiencyOk == "Y") {
        return "pass-color";
      }
      return "";
    },
  },
  {
    prop: "abnormalRatio",
    label: "产线故障率",
    width: 80,
    conditionList: [],
    formatter: (row, col) => {
      return ![undefined, null].includes(row[col.prop]) ? `${row[col.prop]}%` : "";
    },
    fixed: false,
    mergeCell: true,
    background: "#F5F6F7",
    color: "#424656",
    enabledClick: false,
    cellClass: (row, col) => {
      if (row.stoppageRatioOk == "N") {
        return "warning-color";
      } else if (row.stoppageRatioOk == "Y") {
        return "pass-color";
      }
      return "";
    },
  },
  {
    prop: "planOffMinutes",
    label: "计划停机时长(h)",
    width: 80,
    conditionList: [],
    formatter: (row, col) => {
      return ![undefined, null].includes(row[col.prop]) ? toFix(row[col.prop] / 60, 2) : "";
    },
    fixed: false,
    mergeCell: true,
    background: "#F5F6F7",
    color: "#424656",
    enabledClick: false,
  },
  {
    prop: "produceMinutes",
    label: "生产时长",
    width: 80,
    conditionList: [],
    formatter: (row, col) => {
      return ![undefined, null].includes(row[col.prop]) ? toFix(row[col.prop] / 60, 2) : "";
    },
    fixed: false,
    mergeCell: true,
    background: "#F5F6F7",
    color: "#424656",
    enabledClick: false,
  },
  {
    prop: "abnormalStopMinutes",
    label: "产线故障停机时长(h)",
    width: 85,
    conditionList: [],
    formatter: (row, col) => {
      return ![undefined, null].includes(row[col.prop]) ? toFix(row[col.prop] / 60, 2) : "";
    },
    fixed: false,
    mergeCell: true,
    background: "#F5F6F7",
    color: "#424656",
    enabledClick: false,
  },
  {
    prop: "equipName",
    label: "设备名称",
    width: 85,
    conditionList: [],
    fixed: false,
    mergeCell: false,
    background: "#F5F6F7",
    color: "#424656",
    enabledClick: false,
  },
  {
    prop: "equip_abnormalStopTimes",
    label: "故障停机次数",
    width: 85,
    conditionList: [],
    fixed: false,
    mergeCell: false,
    background: "#F5F6F7",
    color: "#424656",
    enabledClick: false,
  },
  {
    prop: "equip_abnormalStopMinutes",
    label: "故障停机时长(min)",
    width: 85,
    conditionList: [],
    fixed: false,
    mergeCell: false,
    background: "#F5F6F7",
    color: "#424656",
    enabledClick: false,
  },
];
